package com.medata.repository;

import com.medata.dataObject.Fj;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface FjRepository extends JpaRepository<Fj,Integer> {

    @Query(value =
            "select * from fj where education = ? or employ = ? or fxy = ? or computer = ? or profession = ?",nativeQuery = true)
    List<Fj> findByEducationOrComputerOrEmployOrFxyOrProfession(
            Integer num1,Integer num2,Integer num3,Integer num4,Integer num5);

    @Query(value =
            "select count(*) from fj where education = ? or employ = ? or fxy = ? or computer = ? or profession = ?",nativeQuery = true)
    Integer unfullCount(Integer num1,Integer num2,Integer num3,Integer num4,Integer num5);

    Page<Fj> getByEducation(Integer number, Pageable pageable);
    Page<Fj> getByEmploy(Integer number, Pageable pageable);
    Page<Fj> getByFxy(Integer number, Pageable pageable);
    Page<Fj> getByComputer(Integer number, Pageable pageable);
    Page<Fj> getByProfession(Integer number, Pageable pageable);

    int countByEducation(Integer number);
    int countByEmploy(Integer number);
    int countByFxy(Integer number);
    int countByComputer(Integer number);
    int countByProfession(Integer number);

    Fj getByDocid(Integer docid);

    void deleteByTitle(String title);
}
